package cn.dglydrpy.study.smartmvc.base.common;

import java.lang.reflect.Method;
/*
 * 为了方便利用java反射调用方法,把方法对象和处理器实例进行封装װ
 */
public class RequestHandler {
	
	private Method method;
	private Object controller;
	
	public Method getMethod() {
		return method;
	}
	public void setMethod(Method method) {
		this.method = method;
	}
	public Object getController() {
		return controller;
	}
	public void setController(Object controller) {
		this.controller = controller;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((controller == null) ? 0 : controller.hashCode());
		result = prime * result + ((method == null) ? 0 : method.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		RequestHandler other = (RequestHandler) obj;
		if (controller == null) {
			if (other.controller != null)
				return false;
		} else if (!controller.equals(other.controller))
			return false;
		if (method == null) {
			if (other.method != null)
				return false;
		} else if (!method.equals(other.method))
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "RequestHandler [method=" + method + ", controller=" + controller + "]";
	}
	public RequestHandler(Method method, Object controller) {
		this.method = method;
		this.controller = controller;
	}
}
